package com.mjk.common.base.error;

import lombok.Getter;

import java.io.Serial;

/**
 * 业务异常类
 */
@Getter
public class BizException extends RuntimeException {
	@Serial
	private static final long serialVersionUID = -5875371379845226068L;

	private String msg;

	private int code;

	public BizException(int code, String msgFormat, Object... args) {
		super(String.format(msgFormat, args));
		this.code = code;
		this.msg = String.format(msgFormat, args);
	}

	public BizException() {
	}

	public BizException newInstance(String msgFormat, Object[] args) {
		return new BizException(this.code, msgFormat, args);
	}

	public BizException(String message, Throwable cause) {
		super(message, cause);
	}

	public BizException(Throwable cause) {
		super(cause);
	}

	public BizException(String message) {
		super(message);
	}
}